﻿using System;
using System.Collections.Generic;
using System.Text;
using My.GenCode.Entities;
using My.GenCode.Interface;

namespace My.GenCode.Templates
{
    public class GenDaoClass : CodeTemplate
    {
        #region 覆盖父类的方法

        public GenDaoClass(string tpl, EntityInfo info, string desc) : base(tpl, info, desc) { }

        protected override string ProcTemplate()
        {
            _tpl = _tpl.Replace("<FileName>", _nh.DaoClassFileName);                 // 处理<FileName>标签
            _tpl = _tpl.Replace("<NameSpace>", _nh.NameSpace);                       // 处理<NameSpace>标签
            _tpl = _tpl.Replace("<ClassName>", _nh.DaoClassName);                    // 处理<ClassName>标签
            _tpl = _tpl.Replace("<EntitiesName>", _nh.EntitiesName);                 // 处理<EntitiesName>标签
            _tpl = _tpl.Replace("<EntityClassName>", _nh.EntityClassName);           // 处理<EntityClassName>标签
            _tpl = _tpl.Replace("<InterfaceName>", _nh.InterfaceName);               // 处理<InterfaceName>标签
            
            _tpl = _tpl.Replace("<CreateMethodName>", _nh.CreateMethodName);         // 处理<CreateMethodName>标签
            _tpl = _tpl.Replace("<UpdateMethodName>", _nh.UpdateMethodName);         // 处理<UpdateMethodName>标签
            _tpl = _tpl.Replace("<DeleteMethodName>", _nh.DeleteMethodName);         // 处理<DeleteMethodName>标签
            _tpl = _tpl.Replace("<ReadDetailMethodName>", _nh.ReadDetailMethodName); // 处理<ReadDetailMethodName>标签
            _tpl = _tpl.Replace("<ReadListMethodName>", _nh.ReadListMethodName);     // 处理<ReadListMethodName>标签
            _tpl = _tpl.Replace("<ReadCountMethodName>", _nh.ReadCountMethodName);   // 处理<ReadCountMethodName>标签

            _tpl = _tpl.Replace("<CreateMethodSign>", _nh.CreateMethodSign);         // 处理<CreateMethodSign>标签
            _tpl = _tpl.Replace("<UpdateMethodSign>", _nh.UpdateMethodSign);         // 处理<UpdateMethodSign>标签
            _tpl = _tpl.Replace("<DeleteMethodSign>", _nh.DeleteMethodSign);         // 处理<DeleteMethodSign>标签
            _tpl = _tpl.Replace("<ReadDetailMethodSign>", _nh.ReadDetailMethodSign); // 处理<ReadDetailMethodSign>标签
            _tpl = _tpl.Replace("<ReadListMethodSign>", _nh.ReadListMethodSign);     // 处理<ReadListMethodSign>标签
            _tpl = _tpl.Replace("<ReadCountMethodSign>", _nh.ReadCountMethodSign);   // 处理<ReadCountMethodSign>标签

            return _tpl;
        }

        protected override string OutputFilename()
        {
            return @"Business\Persistence\" + _nh.DaoClassFileName;
        }

        #endregion
    }
}